{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [],
   "source": [
    "#\n",
    "# 转置 excel 表\n",
    "#\n",
    "import datetime\n",
    "import pandas as pd\n",
    "\n",
    "# 读取数据\n",
    "df = pd.read_excel(\"../../data/1990.xlsx\")\n",
    "# df = pd.read_excel(\"../../data/1990.xlsx\", dtype='str')\n",
    "# print(df)\n",
    "\n",
    "# 改变日期\n",
    "df['日期'] = pd.to_datetime(df['日期'])\n",
    "df['日期'] = df['日期'].dt.strftime('%Y-%m-%d')\n",
    "# print(df)\n",
    "\n",
    "# 转置保存\n",
    "dft = df.transpose()\n",
    "# dft.to_excel(\"../../data/1990_T.xlsx\")\n",
    "dft.to_excel(\"../../data/1990_T.xlsx\", header=False)\n",
    "\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "# import pandas as pd\n",
    "# from openpyxl import load_workbook\n",
    "\n",
    "# book = load_workbook('a.xlsx')\n",
    "# print(book)\n",
    "# writer = pd.ExcelWriter('./a.xlsx', engine='openpyxl')\n",
    "# writer.book = book\n",
    "# df.to_excel(writer, 'x1')\n",
    "# df.to_excel(writer, 'x2')\n"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.10.7 (tags/v3.10.7:6cc6b13, Sep  5 2022, 14:08:36) [MSC v.1933 64 bit (AMD64)]"
  },
  "orig_nbformat": 4,
  "vscode": {
   "interpreter": {
    "hash": "60d0b561bcf179bd0cd76361af4313e00281c3c5daca1903769e6cc3dd82b37c"
   }
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
